<template>
  <el-card header="日志管理">
    <div class="tree-box">
      <MForm :fields="fields" @submit="search" @cancel="search">
        <!--<template #extra>-->
        <!--  <el-button type="primary" @click="exportHtmlToWord">导出</el-button>-->
        <!--</template>-->
      </MForm>
      <MTable
        :columns="columns"
        :http="logList"
        :params="params"
        v-model:isReload="isReload"
        v-model:selectKeys="selectKeys"
      >
        <template #actions="{ row }">
          <MA type="primary" @click="view(row)">查看详情</MA>
        </template>
      </MTable>
      <el-dialog title="查看详情" width="800px" v-model="dialogVisible">
        <el-descriptions>
          <el-descriptions-item label="姓名">{{
            viewInfo.operName
          }}</el-descriptions-item>
          <el-descriptions-item label="工号">{{
            viewInfo.workNo
          }}</el-descriptions-item>
          <el-descriptions-item label="所属单位">{{
            viewInfo.orgName
          }}</el-descriptions-item>
          <el-descriptions-item label="所属部门">{{
            viewInfo.deptName
          }}</el-descriptions-item>
          <el-descriptions-item label="所属应用">{{
            viewInfo.title
          }}</el-descriptions-item>
          <el-descriptions-item label="操作概况">{{
            viewInfo.jsonResult
          }}</el-descriptions-item>
        </el-descriptions>
      </el-dialog>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import { ref, reactive, nextTick } from 'vue'
import { columns, fields, dialogFields } from './config'
import { logExport, logList } from '@/api/system/logManagement'

defineOptions({
  name: 'logManagement'
})

// 搜索
const params = ref<any>({
  typeId: 1
})
const search = (data: any) => {
  params.value = {
    ...params.value,
    ...data
  }
}

// 删除
const selectKeys = ref<number[]>([])
const clearSelectKeysReload = () => {
  selectKeys.value = []
  reload()
}

// 重载
const isReload = ref(true)
const reload = () => {
  isReload.value = true
}

const openDialog = () => {
  dialogVisible.value = true
}

const options = ref([
  {
    label: '主题1',
    value: 1
  },
  {
    label: '主题2',
    value: 2
  },
  {
    label: '主题3',
    value: 3
  }
])

// 新增/编辑
const dialogVisible = ref(false)

const viewInfo = ref({})
const view = (row) => {
  viewInfo.value = row
  dialogVisible.value = true
}

//导出
const exportHtmlToWord = () => {
  logExport().then((data) => {
    // const blob = new Blob([data], { type: 'application/excel;charset=UTF-8' })
    // const a = document.createElement('a')
    // const URL = window.URL || window.webkitURL
    // const herf = URL.createObjectURL(blob)
    // a.href = herf
    // a.download = '报告.docx'
    // document.body.appendChild(a)
    // a.click()
    // document.body.removeChild(a)
    // window.URL.revokeObjectURL(herf)
  })
}
</script>
<style lang="scss" scoped>
.tree-box {
  position: relative;

  .nodeBox {
    width: 100%;
    height: 80vh;
    overflow-x: auto;
    cursor: all-scroll;
  }
  .showLevel {
    position: absolute;
    right: 0;
    top: 0;
  }
}
.dialog-row {
  width: 100%;
  .dialog-col {
    width: 100%;
    display: flex;
    .dialog-col-serialNumber {
      color: #333;
      height: 100%;
      display: flex;
      justify-content: center;
      align-content: center;
      font-weight: bold;
      margin-right: 20px;
    }
    .dialog-col-rig {
      flex: 1;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(237, 237, 237, 1);
      margin-bottom: 20px;
      padding-bottom: 20px;
      .dialog-col-rig-content {
        .dialog-col-rig-content-title {
          font-size: 13px;
          color: #666;
          margin-bottom: 20px;
        }
        .dialog-col-rig-content-form {
          font-size: 13px;
          color: #999;
        }
      }
    }
  }
}
.btns {
  display: flex;
  flex-direction: row-reverse;
}
.ml-20 {
  margin-left: 20px;
}
.ml-12 {
  margin-left: 12px;
}
</style>
